package cn.dengta.webapp.trade.vo;

import java.util.Date;
import java.util.Map;

import cn.dengta.webapp.base.vo.AbstractVO;
import cn.dengta.webapp.trade.entity.UserCoinLog;
import cn.dengta.webapp.trade.model.*;
import lombok.Getter;
import lombok.Setter;
import me.codeplayer.util.*;

/**
 * 钻石流水记录表
 *
 * @author yuqidi
 * @since 2022-03-18
 */
@Setter
@Getter
public class UserCoinLogVO extends AbstractVO<UserCoinLog> {

	/** 交易额度 */
	protected Integer tradeAmount;
	/** 资金总额 */
	protected Integer totalAmount;
	/** 可用余额 */
	protected Integer activeAmount;
	/** 冻结金额 */
	protected Integer frozenAmount;
	/** 赠送可用额度 */
	private Integer freePart;
	/** 本次交易使用的免费额度 */
	protected Integer tradeFreePart;
	/** 订单号 */
	protected String orderNO;
	/** 资金流向：1=收入；0=不变；-1=支出 */
	protected Integer flow;
	/** 用户 */
	protected Map<String, Object> user;
	protected Map<String, Object> agent;
	protected Map<String, Object> toUser;
	protected Map<String, Object> toAgent;
	/** 业务类型 */
	protected transient String tradeType;
	/** 处理状态 */
	protected transient Integer handleStatus;

	public static UserCoinLogVO from(UserCoinLog source) {
		return copy(source, UserCoinLogVO::new);
	}

	public String getFlow_() {
		return X.map(Flow.of(flow), Flow::getLabel);
	}

	public String getTradeType_() {
		return X.map(TradeType.of(tradeType), TradeType::getLabel);
	}

	public String getHandleStatus_() {
		return X.map(HandleStatus.of(handleStatus), HandleStatus::getLabel);
	}

	public String getAddTime_() {
		return super.getAddTime_();
	}

	public Date getAddTime() {
		return super.getAddTime();
	}


	public String getTradeAmount_() {
		return StringUtil.toString(tradeAmount) + (Cmp.nullToZero(tradeFreePart) != 0 ? "（" + tradeFreePart + "）" : "");
	}

}
